﻿<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" 
    x:Class="Berico.SnagL.Infrastructure.Modularity.ToolPanel.RankingToolPanelItemExtensionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:convertors="clr-namespace:Berico.Common.UI.Converters;assembly=Berico.Common"
    mc:Ignorable="d"
    d:DesignHeight="200" d:DesignWidth="300">

    <UserControl.Resources>
        <convertors:EnumBooleanValueConverter x:Key="EnumBooleanConverter" />
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <!-- Control Area -->
        <Grid Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <!-- Background -->
            <Border Grid.Row="0" Grid.RowSpan="2" Height="Auto" Width="Auto" BorderBrush="#FFA5A5A5" BorderThickness="0,0,0,2">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFFFFFF"/>
                        <GradientStop Color="#FFFFFFFF" Offset="1"/>
                        <GradientStop Color="#FFE0E0E0" Offset="0.49"/>
                        <GradientStop Color="#FFE0E0E1" Offset="0.50"/>
                    </LinearGradientBrush>
                </Border.Background>
            </Border>
            
            <!-- Section Header -->
            <Border Grid.Row="0" BorderBrush="#FF8E8E8E" BorderThickness="1" Height="Auto" Width="Auto" HorizontalAlignment="Stretch">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFF0F0F0"/>
                        <GradientStop Color="#FF8C8C8C" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <TextBlock Margin="2" Text="Control Area" TextAlignment="Center" FontWeight="Bold" />
            </Border>
            
            <!-- User Control Layout -->
            <Grid Grid.Row="1" Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="aUTO" />
                </Grid.ColumnDefinitions>
                
                <!-- Control Label -->
                <TextBlock Grid.Row="0" Grid.Column="0" Margin="2,5,0,0" Text="Ranking Algorithm" FontWeight="Bold" />
                
                <!-- Ranking Algorithm List -->
                <ComboBox Grid.Row="1" Grid.Column="0" Margin="2" Height="25" ItemsSource="{Binding Rankers}" SelectedItem="{Binding SelectedRanker, Mode=TwoWay}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}">
                                <ToolTipService.ToolTip>
                                    <ToolTip Content="{Binding Description}" />
                                </ToolTipService.ToolTip>
                            </TextBlock>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                
                <!-- Primary Control Buttons -->
                <StackPanel Grid.Column="1" Grid.RowSpan="2" Margin="2" Orientation="Horizontal">
                    <Button Margin="3" Content="Clear" Height="48" Width="48" HorizontalAlignment="Stretch" IsEnabled="{Binding IsActive}" Command="{Binding ClearRankCommand}" />
                    <Button Margin="3" Content="Rank" Height="48" Width="48" HorizontalAlignment="Stretch" Command="{Binding RankGraphCommand}" />
                </StackPanel>
                
                <!-- Control Label -->
                <TextBlock Grid.Row="2" Grid.Column="0" Margin="2,5,0,0" Text="Visualization Options" FontWeight="Bold" />
                
                <!-- Visiualization Radio Buttons -->
                <StackPanel Grid.Row="3" Grid.ColumnSpan="2" Margin="2" Orientation="Horizontal" HorizontalAlignment="Left">
                    <RadioButton Margin="2" Content="Node Color" GroupName="Viz" IsChecked="{Binding VisualizationOption, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Color, Mode=TwoWay}" />
                    <RadioButton Margin="2" Content="Node Size" GroupName="Viz" IsChecked="{Binding VisualizationOption, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Scale, Mode=TwoWay}" />
                    <RadioButton Margin="2" Content="Both" GroupName="Viz" IsChecked="{Binding VisualizationOption, Converter={StaticResource EnumBooleanConverter}, ConverterParameter=Both, Mode=TwoWay}" />
                </StackPanel>
            </Grid>
        </Grid>

        <!-- Results Area -->
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <!-- Background -->
            <Border Grid.Row="0" Grid.RowSpan="2" Height="Auto" Width="Auto" BorderBrush="#FFA5A5A5" BorderThickness="0,0,0,2">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFFFFFF"/>
                        <GradientStop Color="#FFFFFFFF" Offset="1"/>
                        <GradientStop Color="#FFE0E0E0" Offset="0.49"/>
                        <GradientStop Color="#FFE0E0E1" Offset="0.50"/>
                    </LinearGradientBrush>
                </Border.Background>
            </Border>
            
            <!-- Section Header -->
            <Border Grid.Row="0" BorderBrush="#FF8E8E8E" BorderThickness="1" Height="Auto" Width="Auto" HorizontalAlignment="Stretch">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFF0F0F0"/>
                        <GradientStop Color="#FF8C8C8C" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <TextBlock Margin="2" Text="Results Area" TextAlignment="Center" FontWeight="Bold" />
            </Border>
            
            <!-- Results Chart -->
            <toolkit:Chart Grid.Row="1" Height="Auto" Width="Auto" Visibility="Visible">
                <toolkit:Chart.Series>
                    <toolkit:BarSeries Title="Population" ItemsSource="{Binding Scores}" IndependentValueBinding="{Binding ScoreText}" DependentValueBinding="{Binding NodeCount}"/>
                </toolkit:Chart.Series>
            </toolkit:Chart>
        </Grid>

    </Grid>
</UserControl>
